//
//  MoreTeamViewController.m
//  WE
//
//  Created by iMacOne on 15/11/21.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "MoreTeamViewController.h"
#import "Size.h"
#import "ToolUtil.h"
#import "MoreTeamCell.h"
#import "CityViewController.h"
#import "TeamViewController.h"
@interface MoreTeamViewController ()
@property (nonatomic, strong)UITableView * tableView;

@end

@implementation MoreTeamViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"专家团队";

    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[MoreTeamCell class] forCellReuseIdentifier:@"MoreTeamCell"];
    [self creatBottomView];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
    }

}
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

- (void)creatBottomView
{
    UIView *broundView = [[UIView alloc] initWithFrame:CGRectMake(0, WindowHeight - 49, WindowWidth, 49)];
    broundView.backgroundColor = [UIColor whiteColor];
    NSArray * arr = @[@"杭州",@"默认排序"];
    // broundView.backgroundColor = [UIColor grayColor];
    [ToolUtil createLine:0 superView:broundView lift:0 width:WindowWidth hight:1 color:GRAYCOLOR];
    [ToolUtil createVerticalLine:0 superView:broundView lift:WindowWidth/2 height:49];
    for (int i = 0; i < 2; i++) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(i * WindowWidth /2 -1, 0, WindowWidth/2-1, 49);
        btn.titleLabel.font = FONT(12);
        [btn setTitle:[NSString stringWithFormat:@"%@ ▴",arr[i]] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        btn.tag = 100+i;
//        btn.backgroundColor = [UIColor yellowColor];
        
        [btn addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
        //[cityButton.layer setBorderWidth:1];
        [broundView addSubview:btn];
    }
    [self.view addSubview:broundView];
}
- (void)pressButton:(UIButton *)btn
{
    if (btn.tag == 100) {
        
        [self presentViewController:[[CityViewController alloc] init] animated:YES completion:nil];
    }
}
- (UITableView *)tableView
{
    if (_tableView == nil) {
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 ,WindowWidth , WindowHeight - 49 ) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.rowHeight = 160;
        _tableView.showsVerticalScrollIndicator = NO;

        //        _tableView.scrollEnabled = NO;
    }
    return _tableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellIdentifier = @"MoreTeamCell";
    MoreTeamCell * cell = [[MoreTeamCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    [self.navigationController pushViewController:[[TeamViewController alloc] init] animated:YES];
    
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}
@end
